import matplotlib.pyplot as plt 
import cv2


def main():
	# 原图
	img_1 = cv2.imread("../images/histogram1.tif")
	img_2 = cv2.imread("../images/histogram2.tif")
	img_3 = cv2.imread("../images/histogram3.tif")

	#　原图对应直方图
	img_4 = cv2.imread("../images/histImage1_hist.jpg")
	img_5 = cv2.imread("../images/histImage2_hist.jpg")
	img_6 = cv2.imread("../images/histImage3_hist.jpg")

	# 直方图均衡化后图像
	img_7 = cv2.imread("../images/histogramResult1.jpg")
	img_8 = cv2.imread("../images/histogramResult2.jpg")
	img_9 = cv2.imread("../images/histogramResult3.jpg")

	#　直方图均衡化后直方图
	img_10 = cv2.imread("../images/tempImage_hist.jpg")
	img_11 = cv2.imread("../images/tempImage_2_hist.jpg")
	img_12 = cv2.imread("../images/tempImage_3_hist.jpg")




	img = [img_1, img_4, img_2, img_5, img_3, img_6]

	img2 = [img_1, img_4, img_7, img_10, img_2, img_5, img_8, img_11, img_3, img_6, img_9, img_12];

	plt.figure(1)
	for i in range(6):
		plt.subplot(3, 2, int(i+1))
		plt.imshow(img[int(i)])

	plt.savefig("../images/直方图均衡.jpg")

	plt.figure(2)
	for i in range(12):
		plt.subplot(3, 4, int(i+1))
		plt.imshow(img2[int(i)])

	plt.savefig("../images/直方图均衡化结果.jpg")
	plt.show()


if __name__ == '__main__':
	main()